package com.kedi.healthcenter.service.impl;

import java.util.List;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.kedi.healthcenter.read.dao.mapper.OldlifeMapper;
import com.kedi.healthcenter.service.PcOldLifeService;
import com.kedi.healthcenter.write.dao.mapper.PcOldLifeMapper;

/**
 * 
 *
 * @ClassName PcOldLifeService
 * @author: 陈辽逊
 * @date: 2019/7/17 11:32
 */
@Service
public class PcOldLifeServiceImpl implements PcOldLifeService {

	@Autowired
	private PcOldLifeMapper mapper;

	@Autowired
	OldlifeMapper oldlifeMapper;

	final static Logger logger = LoggerFactory.getLogger(PcOldLifeServiceImpl.class);

	/**
	 * @return 返回一个数据对象
	 */
	@Override
	public List<Map<String, Object>> oldlifepart() {
		try {
			List<Map<String, Object>> a = oldlifeMapper.oldlifepart();
			return a;
		} catch (Exception e) {
			e.printStackTrace();
			logger.error("查询失败");
			return null;
		}
	}

	/**
	 * @return 返回一个数据对象
	 */
	@Override
	public Map<String, Object> oldlifeall(int oldlifeid) {
		try {
			Map<String, Object> a = oldlifeMapper.oldlifeall(oldlifeid);
			return a;
		} catch (Exception e) {
			e.printStackTrace();
			logger.error("查询失败");
			return null;
		}
	}

	/**
	 * @Description: 修改相关床位养老院的信息
	 * @return 返回一个数据对象
	 */
	@Override
	@Transactional(rollbackFor = Exception.class, transactionManager = "secondaryTransactionManager")
	public boolean bedoldlife(Map map) {
		int a = mapper.oldlife(map);
		int b = mapper.bed(map);
		if (a == 1 && b == 1) {
			return true;
		} else {
			return false;
		}
	}

	/**
	 * @Description: 创建相关床位养老院的信息
	 * @return 返回一个数据对象
	 */
	@Override
	@Transactional(rollbackFor = Exception.class, transactionManager = "secondaryTransactionManager")
	public boolean ibedoldlife(Map map) {
		int a = mapper.ioldlife(map);
		int b = mapper.ibed(map);
		if (a == 1 && b == 1) {
			return true;
		} else {
			return false;
		}
	}

	
}
